﻿<%@ Page Title="" Language="C#" MasterPageFile="~/WebmasterTool/Admin.Master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="Framework.WebmasterTool.Orders.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#chkAll").live("change", function () {
                if ($(this).is(":checked")) {
                    $(".checkbox").attr("checked", "checked");
                }
                else {
                    $(".checkbox").removeAttr("checked");
                }
            });
            $(".checkbox").live("click", function () {
                var allCheck = true;
                $(".checkbox").each(function () {
                    if (!$(this).is(":checked")) {
                        allCheck = false;
                        return;
                    }
                });
                if (allCheck == true) {
                    $("#chkAll").attr("checked", "checked");
                }
                else {
                    $("#chkAll").removeAttr("checked");
                }
            });
            $("#<%= btnDelete.ClientID %>").live("click", function () {
                var callFrom = $(this);
                jConfirm('Chắc chắn xoá?', 'Digisky Confirm Dialog',
                function (r) {
                    if (r) {
                        __doPostBack(callFrom.attr('name').replace(/_/g, '$'), '');
                    }
                });
                return false;
            });
        });
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#spanClearDateSearch").click(function () {
                $("#<%= txtDateSearch.ClientID %>").val("");
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ctlCaption" runat="Server">
    Quản lý đơn đặt hàng
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageContent" runat="Server">
    <asp:Label ID="lblPermissionMessage" runat="server" Font-Bold="true" ForeColor="Red"
        Text="Tài khoản không có quyền truy cập vào trang này" Visible="false"></asp:Label>
    <asp:Panel ID="Panel1" runat="server" Visible="true">
        <div style="width: 765px; margin-bottom: 10px;" align="left">
            <span style="display: inline-block; float: left; margin-right: 5px">Tìm kiếm: </span>
            Ngày đăng:
            <asp:TextBox ID="txtDateSearch" runat="server"></asp:TextBox>
            <AjaxControlToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDateSearch"
                Format="dd/MM/yyyy">
            </AjaxControlToolkit:CalendarExtender>
            <AjaxControlToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" MaskType="Date"
                ClearMaskOnLostFocus="true" TargetControlID="txtDateSearch" AcceptAMPM="false"
                Mask="99/99/9999" AutoComplete="false" InputDirection="LeftToRight" ErrorTooltipEnabled="true"
                MessageValidatorTip="true">
            </AjaxControlToolkit:MaskedEditExtender>
            <span id="spanClearDateSearch" style="cursor: pointer;">[x]</span>
            <asp:CheckBox ID="chkIsAnswered" runat="server" Text="Chưa trả lời" />
            <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click" />
            <div style="text-align: right;">
                <asp:Button ID="btnContact" runat="server" Text="Xem liên hệ" OnClick="btnContact_Click" />
            </div>
            <div style="margin: 10px;">
                <asp:GridView runat="server" ID="grvOrder" CssClass="grid" Width="765px" AutoGenerateColumns="False"
                    AllowPaging="True" AllowSorting="True" PagerSettings-Mode="NumericFirstLast"
                    PageSize="10" ToolTip="all" OnDataBinding="grvOrder_DataBinding" OnPageIndexChanging="grvOrder_PageIndexChanging"
                    OnSorting="grvOrder_Sorting">
                    <Columns>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px" HeaderStyle-Width="20px">
                            <HeaderTemplate>
                                <input id="chkAll" type="checkbox" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input id="chkSelect" runat="server" class="checkbox" type="checkbox" title='<%# Eval("OrderID") %>' />
                            </ItemTemplate>
                            <HeaderStyle Width="20px" />
                            <ItemStyle HorizontalAlign="Center" Width="20px" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Người đặt hàng" SortExpression="Receiver" HeaderStyle-HorizontalAlign="Left"
                            ItemStyle-HorizontalAlign="left">
                            <ItemTemplate>
                                <asp:Label ID="lblReceiver" runat="server" Text='<%# bool.Parse(Eval("ViewStatus").ToString()) == true ? Eval("Receiver") : "<B>" + Eval("Receiver") + "</B>"%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Ngày tạo" SortExpression="AddedDate" ItemStyle-Width="120"
                            ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="120">
                            <ItemTemplate>
                                <asp:HiddenField ID="hidfAddedDate" runat="server" Value='<%# Eval("AddedDate") %>' />
                                <asp:Label ID="lblAddedDate" runat="server" Text='<%# String.Format("{0:dd/MM/yyyy HH:mm:ss tt}", (DateTime)(Eval("AddedDate")))%>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Tình trạng" SortExpression="Status"
                            ItemStyle-Width="80" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="130">
                            <ItemTemplate>
                                <asp:Label ID="lblStatus" runat="server" Text='<%# GetStatusOrder(int.Parse(Eval("Status").ToString())) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Trả lời" SortExpression="ReplyStatus"
                            ItemStyle-Width="80" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80">
                            <ItemTemplate>
                                <asp:CheckBox Enabled="false" Checked='<%# bool.Parse(Eval("ReplyStatus").ToString()) == true %>'
                                    ID="chk1" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="40px" ItemStyle-Width="40px" HeaderText=""
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <a href="OrderDetails.aspx?OrderID=<%# Eval("OrderID") %>">
                                    <img src="<%= DGSFramework.Globals.ApplicationPath %>WebmasterTool/Images/Edit.gif"
                                        alt="" border="0" />
                                </a>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <table align="center" width="765px" border="0" bgcolor="#ffffcc">
                            <tr>
                                <td height="50" align="center">
                                    <div align="center" id="EmptyData">
                                        Không có liên hệ khách hàng.</div>
                                </td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                </asp:GridView>
            </div>
        </div>
        <div style="width: 765px; text-align: left">
            <asp:Button runat="server" ID="btnDelete" Text="Xoá các mục đã chọn" OnClick="btnDelete_Click" />
        </div>
    </asp:Panel>
</asp:Content>